package com.ruoyi.demo.controller.app;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.demo.domain.AuctionUserAddress;
import com.ruoyi.demo.service.IAuctionUserAddressService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

@Api(tags = "小程序-用户地址")
@RestController
@RequestMapping("/app/address")
public class AppAuctionUserAddressController extends BaseController {
    @Autowired
    private IAuctionUserAddressService auctionUserAddressService;

    @ApiOperation("查询用户地址列表")
    @GetMapping("/list")
    public TableDataInfo list(AuctionUserAddress auctionUserAddress) {
        startPage();
        List<AuctionUserAddress> list = auctionUserAddressService.selectAuctionUserAddressList(auctionUserAddress);
        return getDataTable(list);
    }

    @ApiOperation("获取用户地址详细信息")
    @GetMapping(value = "/{addressId}")
    public AjaxResult getInfo(@PathVariable("addressId") Long addressId) {
        return success(auctionUserAddressService.selectAuctionUserAddressByAddressId(addressId));
    }

    @ApiOperation("新增用户地址")
    @Log(title = "用户地址", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AuctionUserAddress auctionUserAddress) {
        return toAjax(auctionUserAddressService.insertAuctionUserAddress(auctionUserAddress));
    }

    @ApiOperation("修改用户地址")
    @Log(title = "用户地址", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AuctionUserAddress auctionUserAddress) {
        return toAjax(auctionUserAddressService.updateAuctionUserAddress(auctionUserAddress));
    }

    @ApiOperation("删除用户地址")
    @Log(title = "用户地址", businessType = BusinessType.DELETE)
    @DeleteMapping("/{addressIds}")
    public AjaxResult remove(@PathVariable Long[] addressIds) {
        return toAjax(auctionUserAddressService.deleteAuctionUserAddressByAddressIds(addressIds));
    }
} 